package com.odais.AE_Planner;

import org.andengine.entity.text.Text;
import org.andengine.entity.text.TextOptions;
import org.andengine.opengl.font.Font;
import org.andengine.opengl.font.FontFactory;
import org.andengine.opengl.font.IFont;
import org.andengine.opengl.texture.TextureOptions;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.adt.align.HorizontalAlign;

import com.odais.Reservation.Reservation;

import android.graphics.Color;
import android.graphics.Typeface;


/**
 *
 * @author Lionel DECELLE
 * @since 8 juin 2012 - 10:51:28
 *
 */
public class People extends RoomObject
{
// ===========================================================
// Constants
// ===========================================================

// ===========================================================
// Fields
// ===========================================================
private Reservation reservation = null;

private BitmapTextureAtlas mFontTexture;
private Font mFont;
private Text textCenter;
private SceneContext sceneContext;


	// ===========================================================
// Constructors
// ===========================================================
	public People(SceneContext sceneContext, float mPosX, float mPosY) {
		super(sceneContext, "bugdroid.png", mPosX, mPosY);
		this.sceneContext = sceneContext;

		this.mFont = FontFactory.create(sceneContext.getEngine().getFontManager(), sceneContext.getEngine().getTextureManager(), 256, 256, Typeface.create(Typeface.DEFAULT, Typeface.NORMAL), 20, Color.WHITE);
		this.mFont.load();
		
		VertexBufferObjectManager vertexBufferObjectManager = sceneContext.getEngine().getVertexBufferObjectManager();
		textCenter = new Text(mPosX+this.getWidth()/2, mPosY, this.mFont, "",  20, vertexBufferObjectManager);
	
		sceneContext.getScene().attachChild(textCenter);
	}


// ===========================================================
// Getter & Setter
// ===========================================================


// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================

	public Reservation getReservation() {
		return reservation;
	}

	public void setReservation(Reservation reservation) {
		this.reservation = reservation;
		this.textCenter.setText(this.reservation.getClientName());
	}

	public void setPosition(float pX, float pY)
	{
		this.getSprite().setPosition(pX, pY);
		this.textCenter.setPosition(pX+this.getWidth(), pY+this.getHeight()/2);

	}

	@Override
	public void kill()
	{
		sceneContext.getScene().detachChild(this.getSprite());
		sceneContext.getScene().detachChild(textCenter);
	}

}
